import pygame


class God(pygame.sprite.Sprite):
    def __init__(self, dims, size, img):
        super().__init__()
        self.dims = dims
        self.width, self.height = dims
        self.spw, self.sph = size
        self.image = pygame.transform.scale(img, size)
        # self.spriteScale = pygame.transform.scale(self.image, (50, 50))
        # self.image.fill((random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)))
        self.rect = self.image.get_rect()

        self.rect.center = (self.width/2, self.height-self.sph/2-50)
        self.speed_x = 10

    def move(self, direction):
        if self.rect.x+self.spw>self.width:
            self.rect.x = self.width-self.spw
            return
        elif self.rect.x<0:
            self.rect.x = 0
            return
        if direction == 'right':
            self.rect.x += self.speed_x
            return
            # self.rect.move_ip(self.rect.x+5, self.rect.y)
        elif(direction == 'left'):
            self.rect.x -= self.speed_x
            return
            # self.rect.move_ip(self.rect.x-5, self.rect.y)

    def draw(self, screen):
        screen.blit(self.image, self.rect)